import request from '../utils/request';
let baseURL = '';
export function addMach(data = {}){
    return request.post('/equipment/api/meter/addMeter', { data }, { noprefix:true }).catch(err=>console.log(err));
}
export function getModelList(data={}){
    return request.get('/equipment/api/meter/getMeterModelList', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
// 获取部门列表
export function getDepList(data = {}){
    return request.get('/sys/dept/getDeptList', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}

export function addDep(data = {}){
    return request.post('/sys/dept/addDept', { data }, { noprefix:true }).catch(err=>console.log(err)); 
}
export function updateDep(data = {}){
    return request.post('/sys/dept/updateDept', { data }, { noprefix:true }).catch(err=>console.log(err)); 
}

export function delDep(data = {}){
    return request.delete('/sys/dept/delDept', { data }, { noprefix:true }).catch(err=>console.log(err)); 
}
// 设置角色权限
export function getGlobalMenuList(data = {}){
    return request.get('/sys/menu/getMenuList', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
export function getRoleMenuList(data = {}){
    return request.get('/sys/roleMenuSetting/getSysRoleMenuSetting', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
export function getRoleList(data = {}){
    return request.get('/sys/role/getRoleList', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
export function addRole(data = {}) {
    return request.post('/sys/role/addRole', { data }, { noprefix:true, transformToJson:true  }).catch(err=>console.log(err)); 
}
export function updateRole(data = {}) {
    return request.put('/sys/role/updateRole', { data }, { noprefix:true, transformToJson:true  }).catch(err=>console.log(err)); 
}

export function delRole(data = {}){
    return request.delete('/sys/role/deleteRoleById', { data }, { noprefix:true }).catch(err=>console.log(err)); 
}
// 添加用户

export function getUserList(data = {}){
    return request.get('/sys/user/getEmployeeList', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
export function getUserDetail(data = {}){
    return request.get('/sys/user/getEmployeeById', { data, baseURL, noprefix:true }).catch(err=>console.log(err)); 
}
export function addUser(data = {}) {
    return request.post('/sys/user/addEmployee', { data }, { noprefix:true, transformToJson:true  }).catch(err=>console.log(err)); 
}
export function updateUser(data = {}) {
    return request.post('/sys/user/updateEmployee', { data }, { noprefix:true, transformToJson:true  }).catch(err=>console.log(err)); 
}

export function delUsers(data = {}){
    return request.delete('/sys/user/deleteEmployeeByIds', { data }, { noprefix:true, transformToJson:true }).catch(err=>console.log(err)); 
}
// 操作日志
export function updatePwd(data={}){
    return request.post('/admin/user/bmUpdateUserPassword', {data}).catch(err=>console.log(err));
}
export function getLogList(data={}){
    return request.get('/client/energyOperateLog/getOperateLog', { data, baseURL }).catch(err=>console.log(err));
}

// 上传文件
export function upload(data = {}){
    let formData = new FormData();
    formData.append('file', data.file);
    formData.append('uploadType', data.uploadType);
    return request('/upload/fileUpload', { 
        method:'POST',
        body:formData
        }); 
}
export function getFileBlob(data = {}){
    let str = translateObj(data);
    return request('/upload/getFileByPath?' + str, { 
        method:'GET',
        }); 
}
